﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TorchesTombs
{
    public class ItemThrowMenuItem : ToolStripControlHost
    {
        //constructor
        public ItemThrowMenuItem(ActionMenuItem ami, DungeonPage page)
            : base(new CheckBox())
        {
            _ami = ami;
            _page = page;
            _cb = Control as CheckBox;
            _cb.Text = "Throww";
            _cb.CheckStateChanged += cb_CheckStateChanged;
        }

        //event handler
        private void cb_CheckStateChanged(object sender, EventArgs e)
        {
            _page.CreateDropTargets(_ami.MapObject, _cb.CheckState == CheckState.Checked);
        }

        //unhook
        public void UnHook()
        {
            _cb.CheckStateChanged -= cb_CheckStateChanged;
            _cb = null;
        }

        //private members
        private CheckBox _cb = null;
        private DungeonPage _page;
        private ActionMenuItem _ami;
    }
}
